<template>
  <div class="table-theme">
    <div class="search">
      <div class="searche__item">
        <el-date-picker v-model="query.start_date" type="date" placeholder="选择开始日期" value-format="yyyy-MM-dd"> </el-date-picker>
        <span class="ml5">-</span>
        <el-date-picker v-model="query.end_date" type="date" placeholder="选择结束日期" value-format="yyyy-MM-dd"> </el-date-picker>
        <el-input class="search__input" clearable v-model="query.keyName" placeholder="请输入内容"></el-input>
      </div>
      <div class="searche__item">
        <el-button type="primary" @click="search_data">查询</el-button>
      </div>
    </div>
    <el-table v-loading="tableLoading" border :data="tableList" style="width: 100%" :height="cheight" row-key="id">
      <!-- <el-table-column type="selection" width="55" align="center">
        </el-table-column> -->
      <el-table-column label="工作编号" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.dGZBH }}</span>
        </template>
      </el-table-column>
      <el-table-column label="提单号" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.dTDH }}</span>
        </template>
      </el-table-column>
      <el-table-column label="POL" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.POL }}</span>
        </template>
      </el-table-column>
      <el-table-column label="POD" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.POD }}</span>
        </template>
      </el-table-column>
      <el-table-column label="箱柜数量" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.xgList }}</span>
        </template>
      </el-table-column>
      <el-table-column label="开航日期" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.dKHRQ }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发货人" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.dFHR }}</span>
        </template>
      </el-table-column>
      <el-table-column label="收货人" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.dSHR }}</span>
        </template>
      </el-table-column>
      <el-table-column label="提单状态" width="200px" align="center" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ row.dTDZT }}</span>
        </template>
      </el-table-column>
    </el-table>
    <div>
      <el-pagination
        background
        layout="total,sizes,prev, pager, next"
        :total="recordCount"
        :page-size="query.limit"
        @current-change="pageChange"
        :page-sizes="[25, 100, 200, 300, 400]"
        @size-change="handleSizeChange"
        :current-page.sync="query.page"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        tableLoading: false,
        sel_row: {},
        recordCount: 0,
        query: {
          page: 1,
          limit: 25,
          start_date: '',
          end_date: '',
          keyName: ''
        },
        tableList: [],
        cheight: window.innerHeight - 280
      }
    },

    mounted() {
      this.getList()
    },
    methods: {
      onRowDblclick(row) {
        this.sel_row = { ...row }
      },
      handleSizeChange(val) {
        this.query.limit = val
        this.search_data()
      },
      search_data() {
        this.query.page = 1
        this.getList()
      },
      getList() {
        this.tableLoading = true
        this.tableList = []
        this.recordCount = 0
        this.tableLoading = false
      },
      pageChange(currPage) {
        this.query.page = currPage
        this.getList()
      }
    }
  }
</script>

<style lang="scss" scoped>
  .table-theme {
    .search {
      margin-bottom: 20px;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      .searche__item {
        padding-right: 10px;
        display: flex;
        align-items: center;
        ::v-deep .el-date-editor > .el-input__inner {
          width: 200px;
        }
        .search__input {
          margin-left: 20px;
          ::v-deep .el-input__inner {
            width: 400px;
          }
        }
      }
    }
    ::v-deep .el-table {
      font-size: 14px;
    }
    ::v-deep .el-table thead th {
      background: linear-gradient(to top, #ecf5ff, #b0caf8) !important;
      color: #333;
    }
  }
</style>
